package com.woniuxy01;

import java.util.Objects;

/**
 * @author 作者
 * @create 2025-07-31 14:33
 */
public class User  implements Comparable<User> {
    private Integer uid;
    private String uname;
    private Integer age;

    public User() {
    }

    public User(Integer uid, String uname, Integer age) {
        this.uid = uid;
        this.uname = uname;
        this.age = age;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "uid=" + uid +
                ", uname='" + uname + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        User user = (User) o;
        return Objects.equals(uid, user.uid) && Objects.equals(uname, user.uname) && Objects.equals(age, user.age);
    }

    @Override
    public int hashCode() {
        return Objects.hash(uid, uname, age);
    }


    @Override
    public int compareTo(User o) {
        return o.age - this.age;
    }
}
